<template id='CommonDialog'>
  <div class="CommonDialog" v-if="isShowCommonDialog">
    <div class="cover">
      <div
        class="main animate__animated"
        :class="[
          { animate__bounceIn: isShowCommonDialog },
          { animate__bounceOut: clickColse },
        ]"
      >
        <div class="top">
          <span>{{ dialogInfo.title }}</span>
          <div class="close" @click="closeDialog"></div>
        </div>
        <div class="body">
          <span
            >{{ dialogInfo.message1
            }}<span class="red">{{ dialogInfo.probability }}</span
            ><span>{{ dialogInfo.message2 }}</span></span
          >
        </div>
        <div class="foot">
          <div class="btn" @click="confirm">
            <span>{{ dialogInfo.typeName }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）

export default {
  name: "CommonDialog",
  components: {},
  props: {
    dialogInfo: {
      type: Object,
    },
    isShowCommonDialog: {
      type: Boolean,
      default: false,
    },
    clickColse: {
      type: Boolean,
      default: false,
    },
  },
  // 定义属性
  data() {
    return {};
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    closeDialog() {
      this.$emit("closeCommonDialog");
    },
    confirm() {
      this.$emit("confirmDialog");
      this.closeDialog();
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>

<style lang='less' scoped>
.CommonDialog {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99;
  text-align: center;
  .cover {
    background-color: rgba(0, 0, 0, 0.3);
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    .main {
      background: url("/../../assets/images/game/commonDialogBg.png");
      background-size: 100% 100%;
      width: 600px !important;
      height: 509px !important;
      .top {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 60px;
        font-size: 48px;
        position: relative;
        span {
          height: 83px;
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .close {
          cursor: pointer;
          position: absolute;
          top: 0;
          right: 0;
          background: url("/../../assets/images/game/closeCommonDialog.png");
          width: 76px;
          height: 83px;
          background-size: 100% 100%;
          z-index: 101;
        }
      }
      .body {
        padding: 0 60px;
        margin-top: 67px;
        font-size: 36px;
        line-height: 50px;
        .red {
          color: #ff0000;
        }
      }
      .foot {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 40px;
        .btn {
          background: url(../assets/images/game/myMonkey/type1.png);
          display: flex;
          justify-content: center;
          background-size: 100% 100%;
          width: 238px;
          height: 123px;
          font-size: 48px;
          cursor: pointer;
          span {
            margin-top: 30px;
          }
        }
        .btn:hover {
          background: url(../assets/images/game/myMonkey/type0.png);
          background-size: 100% 100%;
        }
      }
    }
  }
}
@media screen and (max-width: 480px) {
  .CommonDialog {
    .cover {
      .main {
        width: 500px !important;
        height: 424.1px !important;
        .top {
          margin-top: 50px;
          span {
            height: 69px;
            font-size: 36px;
          }
          .close {
            width: 63.33px;
            height: 69.16px;
          }
        }
        .body {
          margin-top: 44px;
          font-size: 30px;
        }
        .foot {
          margin-top: 33px;
          .btn {
            width: 158.6px;
            height: 82px;
            font-size: 32px;
            span {
              margin-top: 18px;
            }
          }
        }
      }
    }
  }
}
</style>